package cn.edu.lzu.unitweb.controller;

import cn.edu.lzu.common.assist.ResponseResult;
import cn.edu.lzu.entity.Examiner;
import cn.edu.lzu.entity.FillRadItem;
import cn.edu.lzu.service.FillRadItemService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.support.DefaultSubjectContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @PackageName: cn.edu.lzu.unitweb.controller
 * @ClassName: FillRadItemController
 * @Description: TODO
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2020/4/6 16:46
 * @Version: 1.0
 */
@Controller
public class FillRadItemController {
    @Resource
    private FillRadItemService fillRadItemService;

    @ResponseBody
    @RequestMapping("/submitRadClauseValue")
    public ResponseResult submitRadClauseValue(FillRadItem fillRadItem){
        Session session= SecurityUtils.getSubject().getSession();
        Examiner examiner=(Examiner)((PrincipalCollection)session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)).getPrimaryPrincipal();
        fillRadItem.setExaminerId(examiner.getExaminerId());
        ResponseResult responseResult=fillRadItemService.fillRadItemValue(fillRadItem);
        return responseResult;
    }
}
